/**
 *
 */
import Util;
import OpenApi;
import OpenApiUtil;
import EndpointUtil;

extends OpenApi;


init(config: OpenApi.Config){
  super(config);
  @endpointRule = '';
  
  checkConfig(config);
  @endpoint = getEndpoint('hsm', @regionId, @endpointRule, @network, @suffix, @endpointMap, @endpoint);
}

function getEndpoint(productId: string, regionId: string, endpointRule: string, network: string, suffix: string, endpointMap: map[string]string, endpoint: string) throws: string{
  if (!Util.empty(endpoint)) {
    return endpoint;
  }
  
  if (!Util.isUnset(endpointMap) && !Util.empty(endpointMap[regionId])) {
    return endpointMap[regionId];
  }
  return EndpointUtil.getEndpointRules(productId, regionId, endpointRule, network, suffix);
}

model ConfigAuditLogRequest {
  auditAction?: string(name='AuditAction', description='The status of the audit log feature.

*   enable
*   disable

This parameter is required.', example='enable'),
  auditOssBucket?: string(name='AuditOssBucket', description='The bucket to which audit logs are delivered.', example='hsm-log'),
  regionId?: string(name='RegionId', description='The ID of the region.

This parameter is required.', example='cn-hangzhou'),
}

model ConfigAuditLogResponseBody = {
  requestId?: string(name='RequestId', description='The request ID.', example='42B118FB-16A6-56FB-B877-D58637EEC6AF'),
}

model ConfigAuditLogResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: ConfigAuditLogResponseBody(name='body'),
}

/**
 * @summary Enables or disables the audit log feature and delivers audit logs to buckets.
 *
 * @description *   The region of the bucket must be the same as the region where the security audit feature is enabled.
 * *   If the security audit feature is enabled, do not delete Object Storage Service (OSS) buckets. If you delete OSS buckets, audit logs fail to be delivered.
 * *   Only electronic virtual security modules (EVSMs) and general virtual security modules (GVSMs) within the Chinese mainland support the security audit feature.
 *
 * @param request ConfigAuditLogRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return ConfigAuditLogResponse
 */
async function configAuditLogWithOptions(request: ConfigAuditLogRequest, runtime: Util.RuntimeOptions): ConfigAuditLogResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.auditAction)) {
    query['AuditAction'] = request.auditAction;
  }
  if (!Util.isUnset(request.auditOssBucket)) {
    query['AuditOssBucket'] = request.auditOssBucket;
  }
  if (!Util.isUnset(request.regionId)) {
    query['RegionId'] = request.regionId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'ConfigAuditLog',
    version = '2023-11-13',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary Enables or disables the audit log feature and delivers audit logs to buckets.
 *
 * @description *   The region of the bucket must be the same as the region where the security audit feature is enabled.
 * *   If the security audit feature is enabled, do not delete Object Storage Service (OSS) buckets. If you delete OSS buckets, audit logs fail to be delivered.
 * *   Only electronic virtual security modules (EVSMs) and general virtual security modules (GVSMs) within the Chinese mainland support the security audit feature.
 *
 * @param request ConfigAuditLogRequest
 * @return ConfigAuditLogResponse
 */
async function configAuditLog(request: ConfigAuditLogRequest): ConfigAuditLogResponse {
  var runtime = new Util.RuntimeOptions{};
  return configAuditLogWithOptions(request, runtime);
}

model ConfigBackupRemarkRequest {
  backupId?: string(name='BackupId', description='This parameter is required.', example='backup-fdb897sdfg****'),
  name?: string(name='Name', example='backup-test'),
  remark?: string(name='Remark'),
}

model ConfigBackupRemarkResponseBody = {
  requestId?: string(name='RequestId', example='4C467B38-3910-447D-87BC-AC049166F216'),
}

model ConfigBackupRemarkResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: ConfigBackupRemarkResponseBody(name='body'),
}

/**
 * @summary 设置备份名与备注
 *
 * @param request ConfigBackupRemarkRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return ConfigBackupRemarkResponse
 */
async function configBackupRemarkWithOptions(request: ConfigBackupRemarkRequest, runtime: Util.RuntimeOptions): ConfigBackupRemarkResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.backupId)) {
    query['BackupId'] = request.backupId;
  }
  if (!Util.isUnset(request.name)) {
    query['Name'] = request.name;
  }
  if (!Util.isUnset(request.remark)) {
    query['Remark'] = request.remark;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'ConfigBackupRemark',
    version = '2023-11-13',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary 设置备份名与备注
 *
 * @param request ConfigBackupRemarkRequest
 * @return ConfigBackupRemarkResponse
 */
async function configBackupRemark(request: ConfigBackupRemarkRequest): ConfigBackupRemarkResponse {
  var runtime = new Util.RuntimeOptions{};
  return configBackupRemarkWithOptions(request, runtime);
}

model ConfigBackupTaskRequest {
  backupHourInDay?: long(name='BackupHourInDay', description='This parameter is required.', example='12'),
  backupId?: string(name='BackupId', description='This parameter is required.', example='backup-173620705****'),
  backupPeriod?: long(name='BackupPeriod', description='This parameter is required.', example='3'),
  manual2PeriodicList?: [ string ](name='Manual2PeriodicList'),
  periodic2ManualList?: [ string ](name='Periodic2ManualList'),
}

model ConfigBackupTaskResponseBody = {
  requestId?: string(name='RequestId', example='4C467B38-3910-447D-87BC-AC049166F216'),
}

model ConfigBackupTaskResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: ConfigBackupTaskResponseBody(name='body'),
}

/**
 * @summary 配置备份自动轮转任务
 *
 * @param request ConfigBackupTaskRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return ConfigBackupTaskResponse
 */
async function configBackupTaskWithOptions(request: ConfigBackupTaskRequest, runtime: Util.RuntimeOptions): ConfigBackupTaskResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.backupHourInDay)) {
    query['BackupHourInDay'] = request.backupHourInDay;
  }
  if (!Util.isUnset(request.backupId)) {
    query['BackupId'] = request.backupId;
  }
  if (!Util.isUnset(request.backupPeriod)) {
    query['BackupPeriod'] = request.backupPeriod;
  }
  if (!Util.isUnset(request.manual2PeriodicList)) {
    query['Manual2PeriodicList'] = request.manual2PeriodicList;
  }
  if (!Util.isUnset(request.periodic2ManualList)) {
    query['Periodic2ManualList'] = request.periodic2ManualList;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'ConfigBackupTask',
    version = '2023-11-13',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary 配置备份自动轮转任务
 *
 * @param request ConfigBackupTaskRequest
 * @return ConfigBackupTaskResponse
 */
async function configBackupTask(request: ConfigBackupTaskRequest): ConfigBackupTaskResponse {
  var runtime = new Util.RuntimeOptions{};
  return configBackupTaskWithOptions(request, runtime);
}

model ConfigClusterCertificateRequest {
  clusterCertificate?: string(name='ClusterCertificate', description='This parameter is required.', example='-----BEGIN CERTIFICATE-----
MIIDaTCCAlECAQEwDQYJKoZIhvcNAQELBQAwVTELMAkGA1UEBhMCY24xCzAJBgNV
BAgMAnpqMQswCQYDVQQHDAJoejEWMBQGA1UECgwNQWxpYmFiYSBDbG91ZDEUMBIG
A1UECwwLU2VjQ2xvdWRIc20wHhcNMjQwNzAzM****-----END CERTIFICATE-----'),
  clusterId?: string(name='ClusterId', description='This parameter is required.', example='cluster-BqxX63Bsg****'),
  issuerCertificate?: string(name='IssuerCertificate', description='This parameter is required.', example='-----BEGIN CERTIFICATE-----
MIIDfTCCAmWgAwIBAgIJAMRqQMr5if66MA0GCSqGSIb3DQEBCwUAMFUxCzAJBgNV
BAYTAmNuMQswCQYDVQQIDAJ6ajELMAkGA1UEBwwCaHoxFjAUBgNVBAoMDUFsaWJh
YmEgQ2xvdWQxFDA****
-----END CERTIFICATE-----'),
}

model ConfigClusterCertificateResponseBody = {
  requestId?: string(name='RequestId', example='4C467B38-3910-447D-87BC-AC049166F216'),
}

model ConfigClusterCertificateResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: ConfigClusterCertificateResponseBody(name='body'),
}

/**
 * @summary 国际站配置HSM集群证书
 *
 * @param request ConfigClusterCertificateRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return ConfigClusterCertificateResponse
 */
async function configClusterCertificateWithOptions(request: ConfigClusterCertificateRequest, runtime: Util.RuntimeOptions): ConfigClusterCertificateResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.clusterCertificate)) {
    body['ClusterCertificate'] = request.clusterCertificate;
  }
  if (!Util.isUnset(request.clusterId)) {
    body['ClusterId'] = request.clusterId;
  }
  if (!Util.isUnset(request.issuerCertificate)) {
    body['IssuerCertificate'] = request.issuerCertificate;
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'ConfigClusterCertificate',
    version = '2023-11-13',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary 国际站配置HSM集群证书
 *
 * @param request ConfigClusterCertificateRequest
 * @return ConfigClusterCertificateResponse
 */
async function configClusterCertificate(request: ConfigClusterCertificateRequest): ConfigClusterCertificateResponse {
  var runtime = new Util.RuntimeOptions{};
  return configClusterCertificateWithOptions(request, runtime);
}

model ConfigClusterNameRequest {
  clusterId?: string(name='ClusterId', description='The cluster ID.

This parameter is required.', example='cluster-BqxX63Bsgfaisdf****'),
  clusterName?: string(name='ClusterName', description='The cluster name.

This parameter is required.', example='cluster_on****'),
}

model ConfigClusterNameResponseBody = {
  requestId?: string(name='RequestId', description='The request ID.', example='4C467B38-3910-447D-87BC-AC049166F216'),
}

model ConfigClusterNameResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: ConfigClusterNameResponseBody(name='body'),
}

/**
 * @summary Modifies the name of a cluster.
 *
 * @param request ConfigClusterNameRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return ConfigClusterNameResponse
 */
async function configClusterNameWithOptions(request: ConfigClusterNameRequest, runtime: Util.RuntimeOptions): ConfigClusterNameResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.clusterId)) {
    body['ClusterId'] = request.clusterId;
  }
  if (!Util.isUnset(request.clusterName)) {
    body['ClusterName'] = request.clusterName;
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'ConfigClusterName',
    version = '2023-11-13',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary Modifies the name of a cluster.
 *
 * @param request ConfigClusterNameRequest
 * @return ConfigClusterNameResponse
 */
async function configClusterName(request: ConfigClusterNameRequest): ConfigClusterNameResponse {
  var runtime = new Util.RuntimeOptions{};
  return configClusterNameWithOptions(request, runtime);
}

model ConfigClusterSubnetRequest {
  clusterId?: string(name='ClusterId', description='This parameter is required.', example='cluster-BqxX63Bsg****'),
  regionId?: string(name='RegionId', description='This parameter is required.', example='cn-hangzhou'),
  vSwitchIds?: [ string ](name='VSwitchIds', description='This parameter is required.'),
  vpcId?: string(name='VpcId', description='This parameter is required.', example='vpc-7xvkh90cw39p0****'),
}

model ConfigClusterSubnetShrinkRequest {
  clusterId?: string(name='ClusterId', description='This parameter is required.', example='cluster-BqxX63Bsg****'),
  regionId?: string(name='RegionId', description='This parameter is required.', example='cn-hangzhou'),
  vSwitchIdsShrink?: string(name='VSwitchIds', description='This parameter is required.'),
  vpcId?: string(name='VpcId', description='This parameter is required.', example='vpc-7xvkh90cw39p0****'),
}

model ConfigClusterSubnetResponseBody = {
  requestId?: string(name='RequestId', example='4C467B38-3910-447D-87BC-AC049366F216'),
}

model ConfigClusterSubnetResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: ConfigClusterSubnetResponseBody(name='body'),
}

/**
 * @summary 配置集群子网
 *
 * @param tmpReq ConfigClusterSubnetRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return ConfigClusterSubnetResponse
 */
async function configClusterSubnetWithOptions(tmpReq: ConfigClusterSubnetRequest, runtime: Util.RuntimeOptions): ConfigClusterSubnetResponse {
  Util.validateModel(tmpReq);
  var request = new ConfigClusterSubnetShrinkRequest{};
  OpenApiUtil.convert(tmpReq, request);
  if (!Util.isUnset(tmpReq.vSwitchIds)) {
    request.vSwitchIdsShrink = OpenApiUtil.arrayToStringWithSpecifiedStyle(tmpReq.vSwitchIds, 'VSwitchIds', 'json');
  }
  var body : map[string]any = {};
  if (!Util.isUnset(request.clusterId)) {
    body['ClusterId'] = request.clusterId;
  }
  if (!Util.isUnset(request.regionId)) {
    body['RegionId'] = request.regionId;
  }
  if (!Util.isUnset(request.vSwitchIdsShrink)) {
    body['VSwitchIds'] = request.vSwitchIdsShrink;
  }
  if (!Util.isUnset(request.vpcId)) {
    body['VpcId'] = request.vpcId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'ConfigClusterSubnet',
    version = '2023-11-13',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary 配置集群子网
 *
 * @param request ConfigClusterSubnetRequest
 * @return ConfigClusterSubnetResponse
 */
async function configClusterSubnet(request: ConfigClusterSubnetRequest): ConfigClusterSubnetResponse {
  var runtime = new Util.RuntimeOptions{};
  return configClusterSubnetWithOptions(request, runtime);
}

model ConfigClusterWhitelistRequest {
  clusterId?: string(name='ClusterId', description='The cluster ID.

This parameter is required.', example='cluster-729dm40FG****'),
  whitelist?: string(name='Whitelist', description='The IP address whitelist of the cluster.

This parameter is required.', example='18.68.XX.XX'),
}

model ConfigClusterWhitelistResponseBody = {
  requestId?: string(name='RequestId', description='The request ID.', example='4C467B38-3910-447D-87BC-AC049166F216'),
}

model ConfigClusterWhitelistResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: ConfigClusterWhitelistResponseBody(name='body'),
}

/**
 * @summary Modifies the IP address whitelist of a cluster.
 *
 * @description The IP address whitelist of a cluster has a higher priority than the IP address whitelist of a hardware security module (HSM) in the cluster. In cluster mode, we recommend that you create an IP address whitelist for your cluster. In this case, you do not need to create an IP address for the HSM in the cluster.
 *
 * @param request ConfigClusterWhitelistRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return ConfigClusterWhitelistResponse
 */
async function configClusterWhitelistWithOptions(request: ConfigClusterWhitelistRequest, runtime: Util.RuntimeOptions): ConfigClusterWhitelistResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.clusterId)) {
    body['ClusterId'] = request.clusterId;
  }
  if (!Util.isUnset(request.whitelist)) {
    body['Whitelist'] = request.whitelist;
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'ConfigClusterWhitelist',
    version = '2023-11-13',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary Modifies the IP address whitelist of a cluster.
 *
 * @description The IP address whitelist of a cluster has a higher priority than the IP address whitelist of a hardware security module (HSM) in the cluster. In cluster mode, we recommend that you create an IP address whitelist for your cluster. In this case, you do not need to create an IP address for the HSM in the cluster.
 *
 * @param request ConfigClusterWhitelistRequest
 * @return ConfigClusterWhitelistResponse
 */
async function configClusterWhitelist(request: ConfigClusterWhitelistRequest): ConfigClusterWhitelistResponse {
  var runtime = new Util.RuntimeOptions{};
  return configClusterWhitelistWithOptions(request, runtime);
}

model ConfigImageRemarkRequest {
  imageId?: string(name='ImageId', description='This parameter is required.', example='image-d79x4k11pmg19****'),
  remark?: string(name='Remark', description='This parameter is required.', example='hsm-****'),
}

model ConfigImageRemarkResponseBody = {
  requestId?: string(name='RequestId', example='4C467B38-3910-447D-87BC-AC049166F216'),
}

model ConfigImageRemarkResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: ConfigImageRemarkResponseBody(name='body'),
}

/**
 * @summary 设置镜像备注
 *
 * @param request ConfigImageRemarkRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return ConfigImageRemarkResponse
 */
async function configImageRemarkWithOptions(request: ConfigImageRemarkRequest, runtime: Util.RuntimeOptions): ConfigImageRemarkResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.imageId)) {
    query['ImageId'] = request.imageId;
  }
  if (!Util.isUnset(request.remark)) {
    query['Remark'] = request.remark;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'ConfigImageRemark',
    version = '2023-11-13',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary 设置镜像备注
 *
 * @param request ConfigImageRemarkRequest
 * @return ConfigImageRemarkResponse
 */
async function configImageRemark(request: ConfigImageRemarkRequest): ConfigImageRemarkResponse {
  var runtime = new Util.RuntimeOptions{};
  return configImageRemarkWithOptions(request, runtime);
}

model ConfigInstanceIpAddressRequest {
  instanceId?: string(name='InstanceId', description='The HSM ID.

This parameter is required.', example='hsm-cn-mp90fxef****'),
  ip?: string(name='Ip', description='The IP address of the HSM in the VPC.

This parameter is required.', example='192.168.XX.XX'),
  regionId?: string(name='RegionId', description='The region ID.

This parameter is required.', example='cn-hangzhou'),
  vSwitchId?: string(name='VSwitchId', description='The vSwitch ID of the subnet to which the HSM belongs.

This parameter is required.', example='vsw-u7gb0qahu****'),
  vpcId?: string(name='VpcId', description='The ID of the VPC to which the HSM belongs.

This parameter is required.', example='vpc-lmkmivmo6****'),
}

model ConfigInstanceIpAddressResponseBody = {
  requestId?: string(name='RequestId', description='The request ID.', example='4C467B38-3910-447D-87BC-AC049166F216'),
}

model ConfigInstanceIpAddressResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: ConfigInstanceIpAddressResponseBody(name='body'),
}

/**
 * @summary Modifies the virtual private cloud (VPC) endpoint of a hardware security module (HSM).
 *
 * @description After you add an HSM to a cluster, you cannot modify the VPC endpoint of the HSM.
 *
 * @param request ConfigInstanceIpAddressRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return ConfigInstanceIpAddressResponse
 */
async function configInstanceIpAddressWithOptions(request: ConfigInstanceIpAddressRequest, runtime: Util.RuntimeOptions): ConfigInstanceIpAddressResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.instanceId)) {
    body['InstanceId'] = request.instanceId;
  }
  if (!Util.isUnset(request.ip)) {
    body['Ip'] = request.ip;
  }
  if (!Util.isUnset(request.regionId)) {
    body['RegionId'] = request.regionId;
  }
  if (!Util.isUnset(request.vSwitchId)) {
    body['VSwitchId'] = request.vSwitchId;
  }
  if (!Util.isUnset(request.vpcId)) {
    body['VpcId'] = request.vpcId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'ConfigInstanceIpAddress',
    version = '2023-11-13',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary Modifies the virtual private cloud (VPC) endpoint of a hardware security module (HSM).
 *
 * @description After you add an HSM to a cluster, you cannot modify the VPC endpoint of the HSM.
 *
 * @param request ConfigInstanceIpAddressRequest
 * @return ConfigInstanceIpAddressResponse
 */
async function configInstanceIpAddress(request: ConfigInstanceIpAddressRequest): ConfigInstanceIpAddressResponse {
  var runtime = new Util.RuntimeOptions{};
  return configInstanceIpAddressWithOptions(request, runtime);
}

model ConfigInstanceRemarkRequest {
  instanceId?: string(name='InstanceId', description='The HSM ID.

This parameter is required.', example='hsm-cn-vj30bil8****'),
  remark?: string(name='Remark', description='The description.

This parameter is required.', example='hsmOnline'),
}

model ConfigInstanceRemarkResponseBody = {
  requestId?: string(name='RequestId', description='The request ID.', example='4C467B38-3910-447D-87BC-AC049166F216'),
}

model ConfigInstanceRemarkResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: ConfigInstanceRemarkResponseBody(name='body'),
}

/**
 * @summary Modifies the description of a hardware security module (HSM).
 *
 * @param request ConfigInstanceRemarkRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return ConfigInstanceRemarkResponse
 */
async function configInstanceRemarkWithOptions(request: ConfigInstanceRemarkRequest, runtime: Util.RuntimeOptions): ConfigInstanceRemarkResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.instanceId)) {
    body['InstanceId'] = request.instanceId;
  }
  if (!Util.isUnset(request.remark)) {
    body['Remark'] = request.remark;
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'ConfigInstanceRemark',
    version = '2023-11-13',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary Modifies the description of a hardware security module (HSM).
 *
 * @param request ConfigInstanceRemarkRequest
 * @return ConfigInstanceRemarkResponse
 */
async function configInstanceRemark(request: ConfigInstanceRemarkRequest): ConfigInstanceRemarkResponse {
  var runtime = new Util.RuntimeOptions{};
  return configInstanceRemarkWithOptions(request, runtime);
}

model ConfigInstanceWhitelistRequest {
  instanceId?: string(name='InstanceId', description='This parameter is required.', example='hsm-cn-vj30bil8****'),
  whitelist?: string(name='Whitelist', description='This parameter is required.', example='18.68.XX.XX,18.68.XX.XX'),
}

model ConfigInstanceWhitelistResponseBody = {
  requestId?: string(name='RequestId', example='4C467B38-3910-447D-87BC-AC049166F216'),
}

model ConfigInstanceWhitelistResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: ConfigInstanceWhitelistResponseBody(name='body'),
}

/**
 * @summary TODO 不允许控制台直接修改集群内实例的白名单实现重构
 *
 * @param request ConfigInstanceWhitelistRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return ConfigInstanceWhitelistResponse
 */
async function configInstanceWhitelistWithOptions(request: ConfigInstanceWhitelistRequest, runtime: Util.RuntimeOptions): ConfigInstanceWhitelistResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.instanceId)) {
    body['InstanceId'] = request.instanceId;
  }
  if (!Util.isUnset(request.whitelist)) {
    body['Whitelist'] = request.whitelist;
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'ConfigInstanceWhitelist',
    version = '2023-11-13',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary TODO 不允许控制台直接修改集群内实例的白名单实现重构
 *
 * @param request ConfigInstanceWhitelistRequest
 * @return ConfigInstanceWhitelistResponse
 */
async function configInstanceWhitelist(request: ConfigInstanceWhitelistRequest): ConfigInstanceWhitelistResponse {
  var runtime = new Util.RuntimeOptions{};
  return configInstanceWhitelistWithOptions(request, runtime);
}

model CopyImageRequest {
  imageUid?: string(name='ImageUid', example='image-hafiudfahdd****'),
  targetRegionId?: string(name='TargetRegionId', example='cn-beijing'),
}

model CopyImageResponseBody = {
  completed?: boolean(name='Completed', example='true'),
  createTime?: string(name='CreateTime', example='1724379766191'),
  error?: string(name='Error', example='OperationTimeout'),
  jobId?: string(name='JobId', example='job-202401250936hze747fd7e0007005'),
  progress?: int32(name='Progress', example='100'),
  requestId?: string(name='RequestId', example='4C467B38-3910-447D-87BC-AC049166F216'),
  response?: string(name='Response', example='success'),
  status?: string(name='Status', example='running'),
  type?: string(name='Type', example='create'),
}

model CopyImageResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: CopyImageResponseBody(name='body'),
}

/**
 * @summary 跨地域复制镜像
 *
 * @param request CopyImageRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return CopyImageResponse
 */
async function copyImageWithOptions(request: CopyImageRequest, runtime: Util.RuntimeOptions): CopyImageResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.imageUid)) {
    body['ImageUid'] = request.imageUid;
  }
  if (!Util.isUnset(request.targetRegionId)) {
    body['TargetRegionId'] = request.targetRegionId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'CopyImage',
    version = '2023-11-13',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary 跨地域复制镜像
 *
 * @param request CopyImageRequest
 * @return CopyImageResponse
 */
async function copyImage(request: CopyImageRequest): CopyImageResponse {
  var runtime = new Util.RuntimeOptions{};
  return copyImageWithOptions(request, runtime);
}

model CreateClusterRequest {
  clusterName?: string(name='ClusterName', description='The cluster name.

This parameter is required.', example='cluster_on****'),
  masterInstanceId?: string(name='MasterInstanceId', description='The HSM ID.

This parameter is required.', example='hsm_intl-sg-uz63ixak****'),
  regionId?: string(name='RegionId', description='The region ID.

This parameter is required.', example='cn-hangzhou'),
}

model CreateClusterResponseBody = {
  clusterId?: string(name='ClusterId', description='The cluster ID.', example='cluster-729dm40FG****'),
  requestId?: string(name='RequestId', description='The request ID.', example='5F58413E-8F57-585B-BE48-64CC1E31133C'),
}

model CreateClusterResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: CreateClusterResponseBody(name='body'),
}

/**
 * @summary Specifies a hardware security module (HSM) as the master HSM to create a cluster.
 *
 * @description The master HSM that you specify to create a cluster must be in the ACTIVE state.
 *
 * @param request CreateClusterRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return CreateClusterResponse
 */
async function createClusterWithOptions(request: CreateClusterRequest, runtime: Util.RuntimeOptions): CreateClusterResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.clusterName)) {
    body['ClusterName'] = request.clusterName;
  }
  if (!Util.isUnset(request.masterInstanceId)) {
    body['MasterInstanceId'] = request.masterInstanceId;
  }
  if (!Util.isUnset(request.regionId)) {
    body['RegionId'] = request.regionId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'CreateCluster',
    version = '2023-11-13',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary Specifies a hardware security module (HSM) as the master HSM to create a cluster.
 *
 * @description The master HSM that you specify to create a cluster must be in the ACTIVE state.
 *
 * @param request CreateClusterRequest
 * @return CreateClusterResponse
 */
async function createCluster(request: CreateClusterRequest): CreateClusterResponse {
  var runtime = new Util.RuntimeOptions{};
  return createClusterWithOptions(request, runtime);
}

model DeleteClusterRequest {
  clusterId?: string(name='ClusterId', description='The cluster ID.

This parameter is required.', example='cluster-NZB9Oj5Yfd8Y****'),
}

model DeleteClusterResponseBody = {
  requestId?: string(name='RequestId', description='The request ID.', example='4C467B38-3910-447D-87BC-AC049166F216'),
}

model DeleteClusterResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: DeleteClusterResponseBody(name='body'),
}

/**
 * @summary Deletes a cluster.
 *
 * @description You can delete a cluster only when no hardware security modules (HSMs) exist in the cluster.
 *
 * @param request DeleteClusterRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return DeleteClusterResponse
 */
async function deleteClusterWithOptions(request: DeleteClusterRequest, runtime: Util.RuntimeOptions): DeleteClusterResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.clusterId)) {
    body['ClusterId'] = request.clusterId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'DeleteCluster',
    version = '2023-11-13',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary Deletes a cluster.
 *
 * @description You can delete a cluster only when no hardware security modules (HSMs) exist in the cluster.
 *
 * @param request DeleteClusterRequest
 * @return DeleteClusterResponse
 */
async function deleteCluster(request: DeleteClusterRequest): DeleteClusterResponse {
  var runtime = new Util.RuntimeOptions{};
  return deleteClusterWithOptions(request, runtime);
}

model DescribeRegionsRequest {
  acceptLanguage?: string(name='AcceptLanguage', example='zh'),
}

model DescribeRegionsResponseBody = {
  regions?: [ 
    {
      localName?: string(name='LocalName'),
      regionId?: string(name='RegionId', example='cn-hangzhou'),
      zones?: [ 
        {
          cluster?: string(name='Cluster', example='yes'),
          localName?: string(name='LocalName'),
          zoneId?: string(name='ZoneId', example='cn-hangzhou-a'),
        }
      ](name='Zones'),
    }
  ](name='Regions'),
  requestId?: string(name='RequestId', example='4C467B38-3910-447D-87BC-AC049166F216'),
}

model DescribeRegionsResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: DescribeRegionsResponseBody(name='body'),
}

/**
 * @param request DescribeRegionsRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return DescribeRegionsResponse
 */
async function describeRegionsWithOptions(request: DescribeRegionsRequest, runtime: Util.RuntimeOptions): DescribeRegionsResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.acceptLanguage)) {
    query['AcceptLanguage'] = request.acceptLanguage;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'DescribeRegions',
    version = '2023-11-13',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @param request DescribeRegionsRequest
 * @return DescribeRegionsResponse
 */
async function describeRegions(request: DescribeRegionsRequest): DescribeRegionsResponse {
  var runtime = new Util.RuntimeOptions{};
  return describeRegionsWithOptions(request, runtime);
}

model EnableBackupRequest {
  backupId?: string(name='BackupId', description='This parameter is required.', example='backup-1736207****'),
  instanceId?: string(name='InstanceId', description='This parameter is required.', example='hsm-cn-mp90fxef****'),
}

model EnableBackupResponseBody = {
  requestId?: string(name='RequestId', example='4C467B38-3910-447D-87BC-AC049166F216'),
}

model EnableBackupResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: EnableBackupResponseBody(name='body'),
}

/**
 * @summary 启用备份
 *
 * @param request EnableBackupRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return EnableBackupResponse
 */
async function enableBackupWithOptions(request: EnableBackupRequest, runtime: Util.RuntimeOptions): EnableBackupResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.backupId)) {
    query['BackupId'] = request.backupId;
  }
  if (!Util.isUnset(request.instanceId)) {
    query['InstanceId'] = request.instanceId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'EnableBackup',
    version = '2023-11-13',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary 启用备份
 *
 * @param request EnableBackupRequest
 * @return EnableBackupResponse
 */
async function enableBackup(request: EnableBackupRequest): EnableBackupResponse {
  var runtime = new Util.RuntimeOptions{};
  return enableBackupWithOptions(request, runtime);
}

model ExportImageRequest {
  imageId?: string(name='ImageId', description='This parameter is required.', example='image-8vbdd5uc6v10ecn5****'),
  instanceId?: string(name='InstanceId', description='This parameter is required.', example='hsm-cn-vj30bil8****'),
}

model ExportImageResponseBody = {
  job?: {
    completed?: boolean(name='Completed', example='true'),
    error?: string(name='Error', example='Job.Canceled'),
    jobId?: string(name='JobId', example='b1748ca6-6b55-49f4-a6d4-2d694a9f3693'),
    process?: int32(name='Process', example='100'),
    response?: string(name='Response', example='success'),
    status?: string(name='Status', example='running'),
    type?: string(name='Type', example='create'),
  }(name='Job'),
  requestId?: string(name='RequestId', example='4C467B38-3910-447D-87BC-AC049166F216'),
}

model ExportImageResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: ExportImageResponseBody(name='body'),
}

/**
 * @summary 手动导出镜像
 *
 * @param request ExportImageRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return ExportImageResponse
 */
async function exportImageWithOptions(request: ExportImageRequest, runtime: Util.RuntimeOptions): ExportImageResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.imageId)) {
    query['ImageId'] = request.imageId;
  }
  if (!Util.isUnset(request.instanceId)) {
    query['InstanceId'] = request.instanceId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'ExportImage',
    version = '2023-11-13',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary 手动导出镜像
 *
 * @param request ExportImageRequest
 * @return ExportImageResponse
 */
async function exportImage(request: ExportImageRequest): ExportImageResponse {
  var runtime = new Util.RuntimeOptions{};
  return exportImageWithOptions(request, runtime);
}

model GetAuditLogStatusRequest {
  getOssBucket?: boolean(name='GetOssBucket', example='true'),
  regionId?: string(name='RegionId', description='This parameter is required.', example='cn-hangzhou'),
}

model GetAuditLogStatusResponseBody = {
  auditLogStatus?: string(name='AuditLogStatus', example='enable'),
  auditOssBucket?: string(name='AuditOssBucket', example='bucket-test'),
  grantedServiceAccess?: boolean(name='GrantedServiceAccess', example='true'),
  ossBuckets?: [ string ](name='OssBuckets'),
  regionId?: string(name='RegionId', example='cn-hangzhou'),
  requestId?: string(name='RequestId', example='4C467B38-3910-447D-87BC-AC049166F216'),
  success?: boolean(name='Success', example='true'),
}

model GetAuditLogStatusResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: GetAuditLogStatusResponseBody(name='body'),
}

/**
 * @summary 查询审计日志功能开通状态
 *
 * @param request GetAuditLogStatusRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return GetAuditLogStatusResponse
 */
async function getAuditLogStatusWithOptions(request: GetAuditLogStatusRequest, runtime: Util.RuntimeOptions): GetAuditLogStatusResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.getOssBucket)) {
    query['GetOssBucket'] = request.getOssBucket;
  }
  if (!Util.isUnset(request.regionId)) {
    query['RegionId'] = request.regionId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'GetAuditLogStatus',
    version = '2023-11-13',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary 查询审计日志功能开通状态
 *
 * @param request GetAuditLogStatusRequest
 * @return GetAuditLogStatusResponse
 */
async function getAuditLogStatus(request: GetAuditLogStatusRequest): GetAuditLogStatusResponse {
  var runtime = new Util.RuntimeOptions{};
  return getAuditLogStatusWithOptions(request, runtime);
}

model GetBackupRequest {
  backupId?: string(name='BackupId', example='backup-fdb897sdf****'),
}

model GetBackupResponseBody = {
  backup?: {
    autoImageCount?: long(name='AutoImageCount', example='1'),
    backupHourInDay?: string(name='BackupHourInDay', example='10'),
    backupId?: string(name='BackupId', example='backup-fdb897sdf****'),
    backupPeriod?: long(name='BackupPeriod', example='3'),
    createTime?: long(name='CreateTime', example='1682417553781'),
    expireTime?: long(name='ExpireTime', example='1682417553781'),
    instanceId?: string(name='InstanceId', example='hsm-cn-5yd35431****'),
    maxImageCount?: string(name='MaxImageCount', example='3'),
    name?: string(name='Name', example='backup-te****'),
    nextImageCreateTime?: long(name='NextImageCreateTime', example='1682417553781'),
    ownerInstanceId?: string(name='OwnerInstanceId', example='hsm-cn-huoahd****'),
    regionId?: string(name='RegionId', example='cn-hangzhou'),
    releaseTime?: long(name='ReleaseTime', example='1641275680000'),
    remark?: string(name='Remark', example='test'),
    spInstanceId?: string(name='SpInstanceId', example='backup-fdb897sdfg53****'),
    status?: string(name='Status', example='NEW'),
    type?: string(name='Type', example='DEFAULT'),
  }(name='Backup'),
  requestId?: string(name='RequestId', example='4C467B38-3910-447D-87BC-AC049166F216'),
}

model GetBackupResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: GetBackupResponseBody(name='body'),
}

/**
 * @summary 展示用户备份
 *
 * @param request GetBackupRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return GetBackupResponse
 */
async function getBackupWithOptions(request: GetBackupRequest, runtime: Util.RuntimeOptions): GetBackupResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.backupId)) {
    query['BackupId'] = request.backupId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'GetBackup',
    version = '2023-11-13',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary 展示用户备份
 *
 * @param request GetBackupRequest
 * @return GetBackupResponse
 */
async function getBackup(request: GetBackupRequest): GetBackupResponse {
  var runtime = new Util.RuntimeOptions{};
  return getBackupWithOptions(request, runtime);
}

model GetClusterRequest {
  clusterId?: string(name='ClusterId', description='The cluster ID.

This parameter is required.', example='cluster-p94y1dud9ts****'),
}

model GetClusterResponseBody = {
  cluster?: {
    clusterCertificate?: string(name='ClusterCertificate', description='The cluster certificate.', example='-----BEGIN CERTIFICATE-----
MIIDfTCCAmWgAwIBAgIJAMRqQMr5if66MA0GCSqGSIb3DQEBCwUAMFUxCzAJBgNV
BAYTAmNuMQswCQYDVQQIDAJ6ajELMAkGA1UEBwwCaHoxFjAUBgNVBAoMDUFsaWJh
YmEgQ2xvdWQxFDA****
-----END CERTIFICATE-----'),
    clusterCsr?: string(name='ClusterCsr', description='The certificate signing request (CSR) file of the cluster.', example='-----BEGIN CERTIFICATE REQUEST-----\\\\nMIIC5TCCAc0CAQAwgZ8xWTAJBgNVBAYTAlVTMAkGA1UECAwCQ0EwDQYDVQQKDAZD\\\\nYXZpdW0wDQYDVQQLDAZOM0ZJUFMwDgYDVQQHDAdTYW5Kb3NlMBMGA1UdEQwMMTk****
-----END CERTIFICATE REQUEST-----'),
    clusterId?: string(name='ClusterId', description='The cluster ID.', example='cluster-p94y1dud9ts****'),
    clusterName?: string(name='ClusterName', description='The cluster name.', example='cluster_polar_****'),
    clusterOwnerCertificate?: string(name='ClusterOwnerCertificate', description='The self-signed certificate of the cluster.', example='----BEGIN CERTIFICATE-----
MIIDaTCCAlECAQEwDQYJKoZIhvcNAQELBQAwVTELMAkGA1UEBhMCY24xCzAJBgNV
BAgMAnpqMQswCQYDVQQHDAJoejEWMBQGA1UECgwNQWxpYmFiYSBDbG91ZDEUMBIG
A1UECwwLU2VjQ2xvdWRIc20wHhcNMjQwNzAzM****
-----END CERTIFICATE-----'),
    createTime?: long(name='CreateTime', description='The time when the cluster was created. Unit: milliseconds. The value is a UNIX timestamp.', example='1641275680000'),
    deviceType?: string(name='DeviceType', description='The device type.', example='jnta'),
    instances?: [ 
      {
        instanceId?: string(name='InstanceId', description='The HSM ID.', example='hsm-cn-g6z3v0uf****'),
        master?: boolean(name='Master', description='Indicates whether the HSM is the master HSM.

*   true
*   false', example='true'),
        nodeId?: int32(name='NodeId', description='The sequence number of the HSM in the cluster.', example='1'),
      }
    ](name='Instances', description='The HSMs in the cluster.'),
    regionId?: string(name='RegionId', description='The ID of the region in which the cluster resides.', example='cn-hangzhou'),
    size?: int32(name='Size', description='The number of hardware security modules (HSMs) in the cluster.', example='2'),
    status?: string(name='Status', description='The cluster status.

*   NEW: The cluster is not initialized.
*   INITIALIZED: The cluster is initialized.
*   DELETED: The cluster is deleted.
*   SYNCHRONIZING: The cluster is being synchronized.
*   TO_DELETE: The cluster is to be deleted.', example='NEW'),
    vpcId?: string(name='VpcId', description='The ID of the virtual private cloud (VPC) to which the cluster belongs.', example='vpc-8vbt0fjdm29hofvbo****'),
    whitelist?: string(name='Whitelist', description='The IP address whitelist of the cluster.', example='130.176.XX.XX'),
    zones?: [ 
      {
        vSwitchId?: string(name='VSwitchId', description='The vSwitch ID.', example='vsw-uf61s651p69bdgmki****'),
        zoneId?: string(name='ZoneId', description='The zone ID.', example='cn-hangzhou-j'),
      }
    ](name='Zones', description='The information about the zone in which the cluster is deployed.'),
  }(name='Cluster', description='The information about the cluster.'),
  requestId?: string(name='RequestId', description='The request ID.', example='4C467B38-3910-447D-87BC-AC049166F216'),
}

model GetClusterResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: GetClusterResponseBody(name='body'),
}

/**
 * @summary Queries information about a cluster.
 *
 * @param request GetClusterRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return GetClusterResponse
 */
async function getClusterWithOptions(request: GetClusterRequest, runtime: Util.RuntimeOptions): GetClusterResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.clusterId)) {
    body['ClusterId'] = request.clusterId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'GetCluster',
    version = '2023-11-13',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary Queries information about a cluster.
 *
 * @param request GetClusterRequest
 * @return GetClusterResponse
 */
async function getCluster(request: GetClusterRequest): GetClusterResponse {
  var runtime = new Util.RuntimeOptions{};
  return getClusterWithOptions(request, runtime);
}

model GetImageRequest {
  imageId?: string(name='ImageId', description='This parameter is required.', example='image-wz9c5ths5dfuwx47****'),
}

model GetImageResponseBody = {
  image?: {
    backupId?: string(name='BackupId', example='backup-1618017313'),
    copyTime?: long(name='CopyTime', example='1641275680000'),
    exportTime?: long(name='ExportTime', example='1786776567788'),
    imageId?: string(name='ImageId', example='image-wz9c5ths5dfuwx47****'),
    instanceId?: string(name='InstanceId', example='hsm-cn-9lb32vll****'),
    mode?: string(name='Mode', example='MANUAL'),
    regionId?: string(name='RegionId', example='cn-hangzhou'),
    remark?: string(name='Remark', example='hsm-test'),
    sourceBackupUid?: string(name='SourceBackupUid', example='backup-gfuiasdfa****'),
    sourceImageUid?: string(name='SourceImageUid', example='image-kklhhhh****'),
    sourceInstanceId?: string(name='SourceInstanceId', example='hsm-wz9fnmvx190shfbk****'),
    sourceRegionId?: string(name='SourceRegionId', example='cn-beijing'),
    status?: string(name='Status', example='NEW'),
    vsmDigest?: string(name='VsmDigest', example='3kGeHnmQzXwSsfF0Jk9eJYhe2gP6An0/HlYIiZh1****'),
  }(name='Image'),
  requestId?: string(name='RequestId', example='4C467B38-3910-447D-87BC-AC049166F216'),
}

model GetImageResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: GetImageResponseBody(name='body'),
}

/**
 * @summary 展示备份下的用户镜像
 *
 * @param request GetImageRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return GetImageResponse
 */
async function getImageWithOptions(request: GetImageRequest, runtime: Util.RuntimeOptions): GetImageResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.imageId)) {
    query['ImageId'] = request.imageId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'GetImage',
    version = '2023-11-13',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary 展示备份下的用户镜像
 *
 * @param request GetImageRequest
 * @return GetImageResponse
 */
async function getImage(request: GetImageRequest): GetImageResponse {
  var runtime = new Util.RuntimeOptions{};
  return getImageWithOptions(request, runtime);
}

model GetInstanceRequest {
  instanceId?: string(name='InstanceId', description='The HSM ID.', example='hsm-cn-vj30bil****'),
}

model GetInstanceResponseBody = {
  instance?: {
    clusterId?: string(name='ClusterId', description='The ID of the cluster to which the HSM belongs.', example='cluster-w3G9vOJI2****'),
    clusterName?: string(name='ClusterName', description='The cluster name.', example='cluster_online'),
    createTime?: long(name='CreateTime', description='The time when the HSM was created.', example='1699515963000'),
    deviceType?: string(name='DeviceType', description='The device type.', example='jnta.SJJ1528-G'),
    expireTime?: long(name='ExpireTime', description='The time when the instance expired.', example='1699496389720'),
    instanceId?: string(name='InstanceId', description='The HSM ID.', example='hsm-cn-g4t3jwsc****'),
    ip?: string(name='Ip', description='The IP address of the HSM in the VPC.', example='10.192.XX.XX'),
    isTrial?: boolean(name='IsTrial', description='Indicates whether the HSM is for trial use. Valid values:

*   true
*   false', example='false'),
    master?: boolean(name='Master', description='Indicates whether the HSM is the master HSM.

*   true
*   false', example='true'),
    orderId?: string(name='OrderId', description='The order ID.', example='23576634952****'),
    regionId?: string(name='RegionId', description='The region ID.', example='cn-hangzhou'),
    remark?: string(name='Remark', description='The HSM description.', example='hsmOnline'),
    status?: string(name='Status', description='The HSM status.

*   PENDING
*   ACTIVE
*   EXPIRED
*   INVALID
*   FAILURE
*   RESET
*   PAUSED
*   MODIFYING', example='EXPIRED'),
    tenantIsolationType?: string(name='TenantIsolationType'),
    vSwitchId?: string(name='VSwitchId', description='The ID of the vSwitch configured for the HSM.', example='vsw-bp1mvfs31ltt0wyhf****'),
    vendor?: string(name='Vendor', description='The vendor information.', example='jnta'),
    vpcId?: string(name='VpcId', description='The ID of the virtual private cloud (VPC) to which the HSM belongs.', example='vpc-uf69i66j9kmoko52p****'),
    whitelist?: string(name='Whitelist', description='The IP address whitelist of the HSM.', example='18.68.XX.XX'),
    zoneId?: string(name='ZoneId', description='The zone ID.', example='cn-hangzhou-b'),
  }(name='Instance', description='The HSM details.'),
  requestId?: string(name='RequestId', description='The request ID.', example='4C467B38-3910-447D-87BC-AC049166F216'),
}

model GetInstanceResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: GetInstanceResponseBody(name='body'),
}

/**
 * @summary Queries information about a hardware security module (HSM).
 *
 * @param request GetInstanceRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return GetInstanceResponse
 */
async function getInstanceWithOptions(request: GetInstanceRequest, runtime: Util.RuntimeOptions): GetInstanceResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.instanceId)) {
    body['InstanceId'] = request.instanceId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'GetInstance',
    version = '2023-11-13',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary Queries information about a hardware security module (HSM).
 *
 * @param request GetInstanceRequest
 * @return GetInstanceResponse
 */
async function getInstance(request: GetInstanceRequest): GetInstanceResponse {
  var runtime = new Util.RuntimeOptions{};
  return getInstanceWithOptions(request, runtime);
}

model GetJobRequest {
  jobId?: string(name='JobId', description='This parameter is required.', example='job-202401250936hze747fd7e0007005'),
}

model GetJobResponseBody = {
  job?: {
    completed?: boolean(name='Completed', example='true'),
    error?: string(name='Error', example='OperationTimeout'),
    jobId?: string(name='JobId', example='job-202401250936hze747fd7e0007005'),
    progress?: long(name='Progress', example='95'),
    response?: string(name='Response', example='success'),
    status?: string(name='Status', example='fail'),
    type?: string(name='Type', example='create'),
  }(name='Job'),
  requestId?: string(name='RequestId', example='4C467B38-3910-447D-87BC-AC049166F216'),
}

model GetJobResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: GetJobResponseBody(name='body'),
}

/**
 * @summary 获取异步任务执行信息
 *
 * @param request GetJobRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return GetJobResponse
 */
async function getJobWithOptions(request: GetJobRequest, runtime: Util.RuntimeOptions): GetJobResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.jobId)) {
    query['JobId'] = request.jobId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'GetJob',
    version = '2023-11-13',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary 获取异步任务执行信息
 *
 * @param request GetJobRequest
 * @return GetJobResponse
 */
async function getJob(request: GetJobRequest): GetJobResponse {
  var runtime = new Util.RuntimeOptions{};
  return getJobWithOptions(request, runtime);
}

model InitializeAuditLogResponseBody = {
  requestId?: string(name='RequestId', example='4FE969D9-E1C7-5274-BE7D-8C3534587605'),
}

model InitializeAuditLogResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: InitializeAuditLogResponseBody(name='body'),
}

/**
 * @summary 为用户创建审计日志的服务关联角色
 *
 * @param request InitializeAuditLogRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return InitializeAuditLogResponse
 */
async function initializeAuditLogWithOptions(runtime: Util.RuntimeOptions): InitializeAuditLogResponse {
  var req = new OpenApi.OpenApiRequest{};
  var params = new OpenApi.Params{
    action = 'InitializeAuditLog',
    version = '2023-11-13',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary 为用户创建审计日志的服务关联角色
 *
 * @return InitializeAuditLogResponse
 */
async function initializeAuditLog(): InitializeAuditLogResponse {
  var runtime = new Util.RuntimeOptions{};
  return initializeAuditLogWithOptions(runtime);
}

model InitializeClusterRequest {
  clusterId?: string(name='ClusterId', description='The cluster ID.

This parameter is required.', example='cluster-p94y1dud9****'),
}

model InitializeClusterResponseBody = {
  requestId?: string(name='RequestId', description='The request ID.', example='4C467B38-3910-447D-87BC-AC049366F216'),
}

model InitializeClusterResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: InitializeClusterResponseBody(name='body'),
}

/**
 * @summary Initializes a cluster.
 *
 * @description *   The cluster is not initialized, but the master hardware security module (HSM) of the cluster is initialized.
 * *   Two or more vSwitches are configured for the cluster.
 *
 * @param request InitializeClusterRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return InitializeClusterResponse
 */
async function initializeClusterWithOptions(request: InitializeClusterRequest, runtime: Util.RuntimeOptions): InitializeClusterResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.clusterId)) {
    body['ClusterId'] = request.clusterId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'InitializeCluster',
    version = '2023-11-13',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary Initializes a cluster.
 *
 * @description *   The cluster is not initialized, but the master hardware security module (HSM) of the cluster is initialized.
 * *   Two or more vSwitches are configured for the cluster.
 *
 * @param request InitializeClusterRequest
 * @return InitializeClusterResponse
 */
async function initializeCluster(request: InitializeClusterRequest): InitializeClusterResponse {
  var runtime = new Util.RuntimeOptions{};
  return initializeClusterWithOptions(request, runtime);
}

model JoinClusterRequest {
  clusterId?: string(name='ClusterId', description='The cluster ID.

This parameter is required.', example='cluster-NZB9Oj5Yfd8Y****'),
  instanceId?: string(name='InstanceId', description='The ID of the HSM that you want to add to the cluster.

This parameter is required.', example='hsm-cn-vj30bil8****'),
}

model JoinClusterResponseBody = {
  job?: {
    completed?: boolean(name='Completed', description='Indicates whether the task is complete. Valid values:

*   true
*   false', example='true'),
    createTime?: string(name='CreateTime', description='The time when the task was created. Unit: milliseconds. The value is a UNIX timestamp.', example='1711764127000'),
    error?: string(name='Error', description='The error message returned if the task fails.', example='OperationTimeout'),
    jobId?: string(name='JobId', description='The task ID.', example='job-202401250936hze747fd7e0007005'),
    progress?: int32(name='Progress', description='The task progress. Unit: percent (%).', example='86'),
    response?: string(name='Response', description='The response parameters.', example='success'),
    status?: string(name='Status', description='The task status. Valid values:

*   success
*   running
*   cancel
*   fail', example='running'),
    type?: string(name='Type', description='The type of the action.

*   create: creates a task.
*   cancel: cancels a task.', example='create'),
  }(name='Job', description='The task details.'),
  requestId?: string(name='RequestId', description='The request ID.', example='4C467B38-3910-447D-87BC-AC049166F216'),
}

model JoinClusterResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: JoinClusterResponseBody(name='body'),
}

/**
 * @summary Adds a hardware security module (HSM) to the current cluster.
 *
 * @description You can add an HSM only to the cluster that is in the INITIALIZED state, and the HSM must be enabled or disabled and is not initialized.
 *
 * @param request JoinClusterRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return JoinClusterResponse
 */
async function joinClusterWithOptions(request: JoinClusterRequest, runtime: Util.RuntimeOptions): JoinClusterResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.clusterId)) {
    body['ClusterId'] = request.clusterId;
  }
  if (!Util.isUnset(request.instanceId)) {
    body['InstanceId'] = request.instanceId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'JoinCluster',
    version = '2023-11-13',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary Adds a hardware security module (HSM) to the current cluster.
 *
 * @description You can add an HSM only to the cluster that is in the INITIALIZED state, and the HSM must be enabled or disabled and is not initialized.
 *
 * @param request JoinClusterRequest
 * @return JoinClusterResponse
 */
async function joinCluster(request: JoinClusterRequest): JoinClusterResponse {
  var runtime = new Util.RuntimeOptions{};
  return joinClusterWithOptions(request, runtime);
}

model LeaveClusterRequest {
  clusterId?: string(name='ClusterId', description='The cluster ID.

This parameter is required.', example='cluster-729dm40FG****'),
  instanceId?: string(name='InstanceId', description='The ID of the HSM that you want to remove from the cluster.

This parameter is required.', example='hsm-cn-mp90fxef****'),
}

model LeaveClusterResponseBody = {
  requestId?: string(name='RequestId', description='The request ID.', example='4C467B38-3910-447D-87BC-AC049166F216'),
}

model LeaveClusterResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: LeaveClusterResponseBody(name='body'),
}

/**
 * @summary Removes a hardware security module (HSM) from the current cluster.
 *
 * @description *   If non-master HSMs exist in a cluster, you cannot remove the master HSM from the cluster.
 * *   After the master HSM is removed from a cluster, the cluster enters the TO_DELETE state and cannot be restored to be available. Proceed with caution.
 *
 * @param request LeaveClusterRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return LeaveClusterResponse
 */
async function leaveClusterWithOptions(request: LeaveClusterRequest, runtime: Util.RuntimeOptions): LeaveClusterResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.clusterId)) {
    body['ClusterId'] = request.clusterId;
  }
  if (!Util.isUnset(request.instanceId)) {
    body['InstanceId'] = request.instanceId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'LeaveCluster',
    version = '2023-11-13',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary Removes a hardware security module (HSM) from the current cluster.
 *
 * @description *   If non-master HSMs exist in a cluster, you cannot remove the master HSM from the cluster.
 * *   After the master HSM is removed from a cluster, the cluster enters the TO_DELETE state and cannot be restored to be available. Proceed with caution.
 *
 * @param request LeaveClusterRequest
 * @return LeaveClusterResponse
 */
async function leaveCluster(request: LeaveClusterRequest): LeaveClusterResponse {
  var runtime = new Util.RuntimeOptions{};
  return leaveClusterWithOptions(request, runtime);
}

model ListBackupsRequest {
  backupId?: string(name='BackupId', example='backup-1648438****'),
  currentPage?: long(name='CurrentPage', description='This parameter is required.', example='1'),
  instanceId?: string(name='InstanceId', example='hsm-cn-vj30bil8****'),
  name?: string(name='Name', example='hsm-te****'),
  pageSize?: long(name='PageSize', description='This parameter is required.', example='20'),
  regionId?: string(name='RegionId', description='This parameter is required.', example='cn-hangzhou'),
}

model ListBackupsResponseBody = {
  backups?: [ 
    {
      autoImageCount?: long(name='AutoImageCount', example='1'),
      backupHourInDay?: string(name='BackupHourInDay', example='13'),
      backupId?: string(name='BackupId', example='backup-1648438****'),
      backupPeriod?: long(name='BackupPeriod', example='3'),
      createTime?: long(name='CreateTime', example='1637229596000'),
      expireTime?: long(name='ExpireTime', example='1682417553781'),
      instanceId?: string(name='InstanceId', example='hsm-cn-vj30bil8****'),
      maxImageCount?: string(name='MaxImageCount', example='3'),
      name?: string(name='Name', example='backup-te****'),
      nextImageCreateTime?: long(name='NextImageCreateTime', example='1682417553781'),
      ownerInstanceId?: string(name='OwnerInstanceId', example='hsm-cn-vj30bil8****'),
      regionId?: string(name='RegionId', example='ap-southeast-1'),
      releaseTime?: long(name='ReleaseTime', example='1641275680000'),
      remark?: string(name='Remark', example='normal backup'),
      spInstanceId?: string(name='SpInstanceId', example='backup-fdb897sdfg534-****'),
      status?: string(name='Status', example='ENABLED'),
      type?: string(name='Type', example='NORMAL'),
    }
  ](name='Backups'),
  currentPage?: int32(name='CurrentPage', example='1'),
  pageSize?: int32(name='PageSize', example='20'),
  requestId?: string(name='RequestId', example='4C467B38-3910-447D-87BC-AC049166F216'),
  totalCount?: int32(name='TotalCount', example='30'),
}

model ListBackupsResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: ListBackupsResponseBody(name='body'),
}

/**
 * @summary 查询备份列表
 *
 * @param request ListBackupsRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return ListBackupsResponse
 */
async function listBackupsWithOptions(request: ListBackupsRequest, runtime: Util.RuntimeOptions): ListBackupsResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.backupId)) {
    query['BackupId'] = request.backupId;
  }
  if (!Util.isUnset(request.currentPage)) {
    query['CurrentPage'] = request.currentPage;
  }
  if (!Util.isUnset(request.instanceId)) {
    query['InstanceId'] = request.instanceId;
  }
  if (!Util.isUnset(request.name)) {
    query['Name'] = request.name;
  }
  if (!Util.isUnset(request.pageSize)) {
    query['PageSize'] = request.pageSize;
  }
  if (!Util.isUnset(request.regionId)) {
    query['RegionId'] = request.regionId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'ListBackups',
    version = '2023-11-13',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary 查询备份列表
 *
 * @param request ListBackupsRequest
 * @return ListBackupsResponse
 */
async function listBackups(request: ListBackupsRequest): ListBackupsResponse {
  var runtime = new Util.RuntimeOptions{};
  return listBackupsWithOptions(request, runtime);
}

model ListClustersRequest {
  currentPage?: int32(name='CurrentPage', description='The page number.

This parameter is required.', example='1'),
  pageSize?: int32(name='PageSize', description='The number of entries per page. Valid values: 1 to 1000.

This parameter is required.', example='20'),
  regionId?: string(name='RegionId', description='The region ID.

This parameter is required.', example='cn-hangzhou'),
}

model ListClustersResponseBody = {
  clusters?: [ 
    {
      clusterId?: string(name='ClusterId', description='The cluster ID.', example='cluster-w3G9vOJI2****'),
      status?: string(name='Status', description='The cluster status.

*   NEW: not initialized
*   INITIALIZED: initialized
*   DELETED: deleted
*   SYNCHRONIZING: being synchronized
*   TO_DELETE: pending deletion', example='INITIALIZED'),
    }
  ](name='Clusters', description='Details of the clusters.'),
  currentPage?: int32(name='CurrentPage', description='The page number.', example='1'),
  pageSize?: int32(name='PageSize', description='The number of entries per page.', example='20'),
  requestId?: string(name='RequestId', description='The request ID.', example='4C467B38-3910-447D-87BC-AC049166F216'),
  total?: int32(name='Total', description='The total number of entries returned.', example='114'),
}

model ListClustersResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: ListClustersResponseBody(name='body'),
}

/**
 * @summary Obtains the clusters that meet the query conditions.
 *
 * @param request ListClustersRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return ListClustersResponse
 */
async function listClustersWithOptions(request: ListClustersRequest, runtime: Util.RuntimeOptions): ListClustersResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.currentPage)) {
    body['CurrentPage'] = request.currentPage;
  }
  if (!Util.isUnset(request.pageSize)) {
    body['PageSize'] = request.pageSize;
  }
  if (!Util.isUnset(request.regionId)) {
    body['RegionId'] = request.regionId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'ListClusters',
    version = '2023-11-13',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary Obtains the clusters that meet the query conditions.
 *
 * @param request ListClustersRequest
 * @return ListClustersResponse
 */
async function listClusters(request: ListClustersRequest): ListClustersResponse {
  var runtime = new Util.RuntimeOptions{};
  return listClustersWithOptions(request, runtime);
}

model ListImagesRequest {
  backupId?: string(name='BackupId', description='This parameter is required.', example='backup-fdb897sdf****'),
  currentPage?: int32(name='CurrentPage', description='This parameter is required.', example='1'),
  mode?: string(name='Mode', example='MANUAL'),
  pageSize?: int32(name='PageSize', description='This parameter is required.', example='20'),
  regionId?: string(name='RegionId', description='This parameter is required.', example='cn-hangzhou'),
}

model ListImagesResponseBody = {
  currentPage?: int32(name='CurrentPage', example='1'),
  images?: [ 
    {
      backupId?: string(name='BackupId', example='backup-fdb897sdf****'),
      copyTime?: string(name='CopyTime', example='1641275680000'),
      exportTime?: long(name='ExportTime', example='1782849566738'),
      imageId?: string(name='ImageId', example='image-d79x4k11pmg19****'),
      instanceId?: string(name='InstanceId', example='hsm-cn-6ja1xknf****'),
      mode?: string(name='Mode', example='MANUAL'),
      regionId?: string(name='RegionId', example='cn-hangzhou'),
      remark?: string(name='Remark', example='hsm-test'),
      sourceBackupUid?: string(name='SourceBackupUid', example='backup-hodfhaol****'),
      sourceImageUid?: string(name='SourceImageUid', example='image-ooopjygsn****'),
      sourceInstanceId?: string(name='SourceInstanceId', example='hsm-cn-wz9i2dmefudfxtmb****'),
      sourceRegionId?: string(name='SourceRegionId', example='cn-shanghai'),
      status?: string(name='Status', example='CREATING'),
      vsmDigest?: string(name='VsmDigest', example='3kGeHnmQzXwSsfF0Jk9eJYhe2gP6An0/HlYIiZh1****'),
    }
  ](name='Images'),
  pageSize?: int32(name='PageSize', example='20'),
  requestId?: string(name='RequestId', example='4C467B38-3910-447D-87BC-AC049166F216'),
  totalCount?: int32(name='TotalCount', example='1000'),
}

model ListImagesResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: ListImagesResponseBody(name='body'),
}

/**
 * @summary 查询用户镜像列表
 *
 * @param request ListImagesRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return ListImagesResponse
 */
async function listImagesWithOptions(request: ListImagesRequest, runtime: Util.RuntimeOptions): ListImagesResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.backupId)) {
    query['BackupId'] = request.backupId;
  }
  if (!Util.isUnset(request.currentPage)) {
    query['CurrentPage'] = request.currentPage;
  }
  if (!Util.isUnset(request.mode)) {
    query['Mode'] = request.mode;
  }
  if (!Util.isUnset(request.pageSize)) {
    query['PageSize'] = request.pageSize;
  }
  if (!Util.isUnset(request.regionId)) {
    query['RegionId'] = request.regionId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'ListImages',
    version = '2023-11-13',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary 查询用户镜像列表
 *
 * @param request ListImagesRequest
 * @return ListImagesResponse
 */
async function listImages(request: ListImagesRequest): ListImagesResponse {
  var runtime = new Util.RuntimeOptions{};
  return listImagesWithOptions(request, runtime);
}

model ListInstancesRequest {
  currentPage?: int32(name='CurrentPage', description='The page number.', example='1'),
  pageSize?: int32(name='PageSize', description='The number of entries per page.', example='20'),
  regionId?: string(name='RegionId', description='The region ID.', example='cn-hangzhou'),
  tenantIsolationType?: string(name='TenantIsolationType'),
}

model ListInstancesResponseBody = {
  currentPage?: int32(name='CurrentPage', description='The page number.', example='1'),
  instances?: [ 
    {
      instanceId?: string(name='InstanceId', description='The HSM ID.', example='hsm-cn-vj30bil8****'),
      status?: string(name='Status', description='The HSM status. PENDING ACTIVE EXPIRED INVALID FAILURE RESET PAUSED MODIFYING', example='ACTIVE'),
    }
  ](name='Instances', description='The HSMs.'),
  pageSize?: int32(name='PageSize', description='The number of entries per page. Valid values: 1 to 1000.', example='20'),
  requestId?: string(name='RequestId', description='The request ID.', example='4C467B38-3910-447D-87BC-AC049166F216'),
  total?: int32(name='Total', description='The total number of entries returned.', example='80'),
}

model ListInstancesResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: ListInstancesResponseBody(name='body'),
}

/**
 * @summary Queries the hardware security modules (HSMs) that meet the query conditions.
 *
 * @param request ListInstancesRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return ListInstancesResponse
 */
async function listInstancesWithOptions(request: ListInstancesRequest, runtime: Util.RuntimeOptions): ListInstancesResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.currentPage)) {
    body['CurrentPage'] = request.currentPage;
  }
  if (!Util.isUnset(request.pageSize)) {
    body['PageSize'] = request.pageSize;
  }
  if (!Util.isUnset(request.regionId)) {
    body['RegionId'] = request.regionId;
  }
  if (!Util.isUnset(request.tenantIsolationType)) {
    body['TenantIsolationType'] = request.tenantIsolationType;
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'ListInstances',
    version = '2023-11-13',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary Queries the hardware security modules (HSMs) that meet the query conditions.
 *
 * @param request ListInstancesRequest
 * @return ListInstancesResponse
 */
async function listInstances(request: ListInstancesRequest): ListInstancesResponse {
  var runtime = new Util.RuntimeOptions{};
  return listInstancesWithOptions(request, runtime);
}

model MoveResourceGroupRequest {
  regionId?: string(name='RegionId', description='This parameter is required.', example='cn-hangzhou'),
  resourceGroupId?: string(name='ResourceGroupId', description='This parameter is required.', example='rg-aek2tsvbnfe****'),
  resourceId?: string(name='ResourceId', description='This parameter is required.', example='hsm-2ze0qae64mjuc0ni****'),
  resourceType?: string(name='ResourceType', description='This parameter is required.', example='instance'),
}

model MoveResourceGroupResponseBody = {
  requestId?: string(name='RequestId', example='4C467B38-3910-447D-87BC-AC049166F216'),
}

model MoveResourceGroupResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: MoveResourceGroupResponseBody(name='body'),
}

/**
 * @summary 资源组移动资源
 *
 * @param request MoveResourceGroupRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return MoveResourceGroupResponse
 */
async function moveResourceGroupWithOptions(request: MoveResourceGroupRequest, runtime: Util.RuntimeOptions): MoveResourceGroupResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.regionId)) {
    query['RegionId'] = request.regionId;
  }
  if (!Util.isUnset(request.resourceGroupId)) {
    query['ResourceGroupId'] = request.resourceGroupId;
  }
  if (!Util.isUnset(request.resourceId)) {
    query['ResourceId'] = request.resourceId;
  }
  if (!Util.isUnset(request.resourceType)) {
    query['ResourceType'] = request.resourceType;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'MoveResourceGroup',
    version = '2023-11-13',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary 资源组移动资源
 *
 * @param request MoveResourceGroupRequest
 * @return MoveResourceGroupResponse
 */
async function moveResourceGroup(request: MoveResourceGroupRequest): MoveResourceGroupResponse {
  var runtime = new Util.RuntimeOptions{};
  return moveResourceGroupWithOptions(request, runtime);
}

model PauseInstanceRequest {
  instanceId?: string(name='InstanceId', description='The HSM ID.

This parameter is required.', example='hsm-cn-vj30bil8****'),
}

model PauseInstanceResponseBody = {
  requestId?: string(name='RequestId', description='The request ID.', example='4C467B38-3910-447D-87BC-AC049366F216'),
}

model PauseInstanceResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: PauseInstanceResponseBody(name='body'),
}

/**
 * @summary Deactivates a hardware security module (HSM).
 *
 * @description After you deactivate an HSM, the relevant service operations fail. Proceed with caution.
 *
 * @param request PauseInstanceRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return PauseInstanceResponse
 */
async function pauseInstanceWithOptions(request: PauseInstanceRequest, runtime: Util.RuntimeOptions): PauseInstanceResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.instanceId)) {
    body['InstanceId'] = request.instanceId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'PauseInstance',
    version = '2023-11-13',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary Deactivates a hardware security module (HSM).
 *
 * @description After you deactivate an HSM, the relevant service operations fail. Proceed with caution.
 *
 * @param request PauseInstanceRequest
 * @return PauseInstanceResponse
 */
async function pauseInstance(request: PauseInstanceRequest): PauseInstanceResponse {
  var runtime = new Util.RuntimeOptions{};
  return pauseInstanceWithOptions(request, runtime);
}

model QuickInitInstanceRequest {
  instanceId?: string(name='InstanceId', description='The HSM ID.

This parameter is required.', example='hsm-cn-mp90fxef****'),
}

model QuickInitInstanceResponseBody = {
  job?: {
    completed?: boolean(name='Completed', description='Indicates whether the task is complete.', example='true'),
    createTime?: string(name='CreateTime', description='The time when the task was created. Unit: milliseconds. The value is a UNIX timestamp.', example='1699515963000'),
    error?: string(name='Error', description='The error message returned if the task fails.', example='OperationTimeout'),
    jobId?: string(name='JobId', description='The task ID.', example='job-000fi9k1v2hclo321sal'),
    progress?: int32(name='Progress', description='The task progress. Unit: percent (%).', example='100'),
    response?: string(name='Response', description='The response parameters.', example='success'),
    status?: string(name='Status', description='The task status. Valid values: success running cancel fail', example='success'),
    type?: string(name='Type', description='The type of the SQL statement. Valid values: create: creates a task. cancel: cancels a task.', example='create'),
  }(name='Job', description='The task details.'),
  requestId?: string(name='RequestId', description='The request ID.', example='4C467B38-3910-447D-87BC-AC049366F216'),
}

model QuickInitInstanceResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: QuickInitInstanceResponseBody(name='body'),
}

/**
 * @summary Initializes a hardware security module (HSM).
 *
 * @description This operation is supported only for general virtual security modules (GVSMs) that are deployed in regions in the Chinese mainland.
 *
 * @param request QuickInitInstanceRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return QuickInitInstanceResponse
 */
async function quickInitInstanceWithOptions(request: QuickInitInstanceRequest, runtime: Util.RuntimeOptions): QuickInitInstanceResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.instanceId)) {
    body['InstanceId'] = request.instanceId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'QuickInitInstance',
    version = '2023-11-13',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary Initializes a hardware security module (HSM).
 *
 * @description This operation is supported only for general virtual security modules (GVSMs) that are deployed in regions in the Chinese mainland.
 *
 * @param request QuickInitInstanceRequest
 * @return QuickInitInstanceResponse
 */
async function quickInitInstance(request: QuickInitInstanceRequest): QuickInitInstanceResponse {
  var runtime = new Util.RuntimeOptions{};
  return quickInitInstanceWithOptions(request, runtime);
}

model ResetBackupRequest {
  backupId?: string(name='BackupId', example='backup-fdb897sdfg5****'),
}

model ResetBackupResponseBody = {
  requestId?: string(name='RequestId', example='4C467B38-3910-447D-87BC-AC049166F216'),
}

model ResetBackupResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: ResetBackupResponseBody(name='body'),
}

/**
 * @summary 重置备份
 *
 * @param request ResetBackupRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return ResetBackupResponse
 */
async function resetBackupWithOptions(request: ResetBackupRequest, runtime: Util.RuntimeOptions): ResetBackupResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.backupId)) {
    query['BackupId'] = request.backupId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'ResetBackup',
    version = '2023-11-13',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary 重置备份
 *
 * @param request ResetBackupRequest
 * @return ResetBackupResponse
 */
async function resetBackup(request: ResetBackupRequest): ResetBackupResponse {
  var runtime = new Util.RuntimeOptions{};
  return resetBackupWithOptions(request, runtime);
}

model ResetInstanceRequest {
  instanceId?: string(name='InstanceId', description='The HSM ID.

This parameter is required.', example='hsm-cn-vj30bil8****'),
}

model ResetInstanceResponseBody = {
  job?: {
    completed?: boolean(name='Completed', description='Indicates whether the task is complete. Valid values:', example='true'),
    createTime?: string(name='CreateTime', description='The time when the task was created. Unit: milliseconds. The value is a UNIX timestamp.', example='1653274407000'),
    error?: string(name='Error', description='The error message returned if the task fails.', example='OperationTimeout'),
    jobId?: string(name='JobId', description='The task ID.', example='job-0007bl8oev0u3jqyfu6a'),
    progress?: int32(name='Progress', description='The task progress. Unit: percent (%).', example='80'),
    response?: string(name='Response', description='The response parameters.', example='success'),
    status?: string(name='Status', description='The task status. Valid values: success running cancel fail', example='success'),
    type?: string(name='Type', description='The type of the action. create: creates a task. cancel: cancels a task.', example='create'),
  }(name='Job', description='The task details.'),
  requestId?: string(name='RequestId', description='The request ID.', example='4C467B38-3910-447D-87BC-AC049166F216'),
}

model ResetInstanceResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: ResetInstanceResponseBody(name='body'),
}

/**
 * @summary Resets a hardware security module (HSM).
 *
 * @description After an HSM is reset, all related data is deleted and cannot be recovered. Exercise caution.
 *
 * @param request ResetInstanceRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return ResetInstanceResponse
 */
async function resetInstanceWithOptions(request: ResetInstanceRequest, runtime: Util.RuntimeOptions): ResetInstanceResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.instanceId)) {
    body['InstanceId'] = request.instanceId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'ResetInstance',
    version = '2023-11-13',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary Resets a hardware security module (HSM).
 *
 * @description After an HSM is reset, all related data is deleted and cannot be recovered. Exercise caution.
 *
 * @param request ResetInstanceRequest
 * @return ResetInstanceResponse
 */
async function resetInstance(request: ResetInstanceRequest): ResetInstanceResponse {
  var runtime = new Util.RuntimeOptions{};
  return resetInstanceWithOptions(request, runtime);
}

model RestoreInstanceRequest {
  imageId?: string(name='ImageId', description='The ID of the image that you want to use to restore the HSM.

This parameter is required.', example='image-eaOGHkRDQgh4****'),
  instanceId?: string(name='InstanceId', description='The HSM ID.

This parameter is required.', example='hsm-cn-mp90fxef****'),
}

model RestoreInstanceResponseBody = {
  job?: {
    completed?: boolean(name='Completed', description='Indicates whether the task is complete.', example='true'),
    createTime?: string(name='CreateTime', description='The time when the task was created. Unit: milliseconds. The value is a UNIX timestamp.', example='1711764127000'),
    error?: string(name='Error', description='The error message returned if the task fails.', example='OperationTimeout'),
    jobId?: string(name='JobId', description='The task ID.', example='job-540356379023708160'),
    progress?: int32(name='Progress', description='The task progress. Unit: percent (%).', example='50'),
    response?: string(name='Response', description='The response returned if the task succeeds.', example='success'),
    status?: string(name='Status', description='The task status. Valid values:', example='success'),
    type?: string(name='Type', description='The type of the action. Valid values: create: creates a task. cancel: cancels a task.', example='create'),
  }(name='Job', description='The task details.'),
  requestId?: string(name='RequestId', description='The request ID.', example='4C467B38-3910-447D-87BC-AC049366F216'),
}

model RestoreInstanceResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: RestoreInstanceResponseBody(name='body'),
}

/**
 * @summary Restores a hardware security module (HSM) by using an image.
 *
 * @description You can use images to restore only HSMs that are suspended or deactivated.
 *
 * @param request RestoreInstanceRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return RestoreInstanceResponse
 */
async function restoreInstanceWithOptions(request: RestoreInstanceRequest, runtime: Util.RuntimeOptions): RestoreInstanceResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.imageId)) {
    body['ImageId'] = request.imageId;
  }
  if (!Util.isUnset(request.instanceId)) {
    body['InstanceId'] = request.instanceId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'RestoreInstance',
    version = '2023-11-13',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary Restores a hardware security module (HSM) by using an image.
 *
 * @description You can use images to restore only HSMs that are suspended or deactivated.
 *
 * @param request RestoreInstanceRequest
 * @return RestoreInstanceResponse
 */
async function restoreInstance(request: RestoreInstanceRequest): RestoreInstanceResponse {
  var runtime = new Util.RuntimeOptions{};
  return restoreInstanceWithOptions(request, runtime);
}

model ResumeInstanceRequest {
  instanceId?: string(name='InstanceId', description='The HSM ID.

This parameter is required.', example='hsm-cn-vj30bil8****'),
}

model ResumeInstanceResponseBody = {
  requestId?: string(name='RequestId', description='The request ID.', example='4C467B38-3910-447D-87BC-AC049166F216'),
}

model ResumeInstanceResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: ResumeInstanceResponseBody(name='body'),
}

/**
 * @summary Resumes a deactivated hardware security module (HSM).
 *
 * @param request ResumeInstanceRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return ResumeInstanceResponse
 */
async function resumeInstanceWithOptions(request: ResumeInstanceRequest, runtime: Util.RuntimeOptions): ResumeInstanceResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.instanceId)) {
    body['InstanceId'] = request.instanceId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'ResumeInstance',
    version = '2023-11-13',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary Resumes a deactivated hardware security module (HSM).
 *
 * @param request ResumeInstanceRequest
 * @return ResumeInstanceResponse
 */
async function resumeInstance(request: ResumeInstanceRequest): ResumeInstanceResponse {
  var runtime = new Util.RuntimeOptions{};
  return resumeInstanceWithOptions(request, runtime);
}

model SwitchClusterMasterRequest {
  clusterId?: string(name='ClusterId', description='The cluster ID.

This parameter is required.', example='cluster-w3G9vOJI2****'),
  instanceId?: string(name='InstanceId', description='The ID of the HSM that you want to promote to the master HSM.

This parameter is required.', example='hsm-cn-vj30bil8****'),
}

model SwitchClusterMasterResponseBody = {
  requestId?: string(name='RequestId', description='The request ID.', example='4C467B38-3910-447D-87BC-AC049166F216'),
}

model SwitchClusterMasterResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: SwitchClusterMasterResponseBody(name='body'),
}

/**
 * @summary Promote a non-master hardware security module (HSM) in a cluster to the master HSM.
 *
 * @param request SwitchClusterMasterRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return SwitchClusterMasterResponse
 */
async function switchClusterMasterWithOptions(request: SwitchClusterMasterRequest, runtime: Util.RuntimeOptions): SwitchClusterMasterResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.clusterId)) {
    body['ClusterId'] = request.clusterId;
  }
  if (!Util.isUnset(request.instanceId)) {
    body['InstanceId'] = request.instanceId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'SwitchClusterMaster',
    version = '2023-11-13',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary Promote a non-master hardware security module (HSM) in a cluster to the master HSM.
 *
 * @param request SwitchClusterMasterRequest
 * @return SwitchClusterMasterResponse
 */
async function switchClusterMaster(request: SwitchClusterMasterRequest): SwitchClusterMasterResponse {
  var runtime = new Util.RuntimeOptions{};
  return switchClusterMasterWithOptions(request, runtime);
}

model SyncClusterRequest {
  clusterId?: string(name='ClusterId', description='The cluster ID.

This parameter is required.', example='cluster-BqxX63Bsgytet****'),
}

model SyncClusterResponseBody = {
  job?: {
    completed?: boolean(name='Completed', description='Indicates whether the task is complete. Valid values:

*   true
*   false', example='true'),
    createTime?: string(name='CreateTime', description='The time when the task was created. Unit: milliseconds. The value is a UNIX timestamp.', example='1711764127000'),
    error?: string(name='Error', description='The error message returned if the task fails.', example='OperationTimeout'),
    jobId?: string(name='JobId', description='The task ID.', example='job-000bu7m5vjmyz9s7qz85'),
    progress?: int32(name='Progress', description='The task progress. Unit: percent (%).', example='90'),
    response?: string(name='Response', description='The response parameters.', example='success'),
    status?: string(name='Status', description='The task status. Valid values:

*   success
*   running
*   cancel
*   fail', example='success'),
    type?: string(name='Type', description='The type of the action.

*   create: creates a task.
*   cancel: cancels a task.', example='create'),
  }(name='Job', description='The task details.'),
  requestId?: string(name='RequestId', description='The request ID.', example='4C467B38-3910-447D-87BC-AC049166F216'),
}

model SyncClusterResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: SyncClusterResponseBody(name='body'),
}

/**
 * @summary Synchronizes HSM data in a cluster.
 *
 * @description This operation is supported only for hardware security modules (HSMs) that are created in regions in the Chinese mainland.
 *
 * @param request SyncClusterRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return SyncClusterResponse
 */
async function syncClusterWithOptions(request: SyncClusterRequest, runtime: Util.RuntimeOptions): SyncClusterResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.clusterId)) {
    body['ClusterId'] = request.clusterId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'SyncCluster',
    version = '2023-11-13',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary Synchronizes HSM data in a cluster.
 *
 * @description This operation is supported only for hardware security modules (HSMs) that are created in regions in the Chinese mainland.
 *
 * @param request SyncClusterRequest
 * @return SyncClusterResponse
 */
async function syncCluster(request: SyncClusterRequest): SyncClusterResponse {
  var runtime = new Util.RuntimeOptions{};
  return syncClusterWithOptions(request, runtime);
}

